package com.Q03;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.Random;

/**
 * @version v1.0.0
 * 创建时间：2022/6/28 18:37
 */
public class Q03_06 {

}
class AnimalShelf {
    // linkedlist<>
    LinkedList<int[]> catList;
    LinkedList<int[]> dogList;

    public AnimalShelf() {
        catList = new LinkedList<int[]>();
        dogList = new LinkedList<>();
    }

    public void enqueue(int[] animal) {
        if (animal[1]==0){
            catList.add(animal);
        }else {
            dogList.add(animal);
        }
    }

    public int[] dequeueAny() {
        if (!catList.isEmpty() && !dogList.isEmpty())
            return catList.get(0)[0]<dogList.get(0)[0]?catList.removeFirst():dogList.removeFirst();

        if (!catList.isEmpty()) return catList.removeFirst();
        if (!dogList.isEmpty()) return dogList.removeFirst();
        return new int[]{-1,-1};
    }

    public int[] dequeueDog() {
        if (dogList.isEmpty()) return new int[]{-1,-1};
        return dogList.removeFirst();
    }

    public int[] dequeueCat() {
        if (catList.isEmpty()) return new int[]{-1,-1};
        return catList.removeFirst();
    }
}